package pages;

import model.Customer;

import org.apache.wicket.ajax.markup.html.navigation.paging.AjaxPagingNavigator;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.data.DataView;

import dataprovider.CustomerDataProvider;


public class CustomerList extends BasePage {
	
	@SuppressWarnings("serial")
	public CustomerList(){
		WebMarkupContainer container = new WebMarkupContainer("table");
		DataView dataView = new DataView("dataView", new CustomerDataProvider(), 5) {
			
			@Override
			protected void populateItem(Item item) {
				Customer customer = (Customer) item.getModelObject();
				item.add(new Label("itemId", String.valueOf(customer.getId())));
				item.add(new Label("itemFirst", customer.getFirstName()));
				item.add(new Label("itemLast", customer.getLastName()));
			}
		};
		container.add(dataView);
		container.setOutputMarkupId(true);
		add(container);
		
		AjaxPagingNavigator navigator = new AjaxPagingNavigator("paging", dataView);
        navigator.setOutputMarkupPlaceholderTag(true);
        add(navigator);
	}
}
